#include <bits/stdc++.h>
using namespace std;

#define NAME "detect"
#define sqr(x) (x * x)
typedef long long ll;
const int INF = 2e9;
const ll LINF = 4e18;
const int MAXN = 1e5 + 5;

int n, m, L, V;
int d[MAXN], v[MAXN], a[MAXN], p[MAXN];

void solve(){
    cin >> n >> m >> L >> V;
    for (int i = 0; i < n; i++){
        cin >> d[i] >> v[i] >> a[i];
    }
    for (int i = 0; i < m; i++){
        cin >> p[i];
    }
    bool special = 1;
    vector <pair <int, int>> r;
    for (int i = 0; i < n; i++){
        if (a[i] < 0) special = 0;
        if (a[i] == 0 or a[i] > 0 and v[i] > V){
            if (v[i] > V and d[i] <= p[m - 1]){
                r.push_back(make_pair(L + 10, d[i]));
            }
        }
        else if (a[i] > 0){
            int x = d[i] + (sqr(V) - sqr(v[i])) / (2 * a[i]) + 1;
            if (x <= p[m - 1]){
                r.push_back(make_pair(L + 10, x));
            }
        }
        else if (v[i] > V){
            int x = d[i] + (abs(sqr(V) - sqr(v[i])) - 1) / abs(2 * a[i]);
            int indx = lower_bound(p, p + m, d[i]) - p;
            if (indx < m and p[indx] <= x){
                r.push_back(make_pair(min(x, L + 10), d[i]));
            }
        }
    }
    cout << r.size() << ' ';
    if (special){
        if (r.size() == 0) cout << m << endl;
        else cout << m - 1 << endl;
        return ;
    }
    sort(r.begin(), r.end());
    p[m++] = L + 15;
    int cnt = 0, sel = -1, last = -1, pnt = 0;
    for (int i = 0; i < m; i++){
        while (pnt < r.size() and r[pnt].second <= sel) pnt++;
        if (pnt == r.size()) break;
        if (pnt < r.size() and r[pnt].first < p[i]){
            cnt++;
            sel = last;
        }
        last = p[i];
    }
    cout << m - cnt - 1 << endl;
}

int main(){
    freopen(NAME ".in", "r", stdin);
    freopen(NAME ".out", "w", stdout);

    int t; cin >> t;
    while (t--) solve();
    return 0;
}